<template>
  <div style="font-size: 12px;line-height: 60px;display: flex;">
    <div style="flex: 1; ">
      <span :class="collapseBtnClass" style="cursor: pointer;font-size: 19px" @click="collapse"></span>
    </div>

    <el-dropdown style="width: 150px; cursor: pointer;text-align: right">
      <div style="display: inline-block">
        <img :src="user.avatar" alt=""
             style="width: 30px; height:30px; border-radius: 50%; position: relative; top: 10px; right: 5px">
        <span>{{user.name}}</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
      </div>
      <el-dropdown-menu slot="dropdown" style="width: 90px;text-align: center">
        <el-dropdown-item style="font-size: 14px;padding: 5px 0">
          <router-link to="/person" tag="span">个人信息</router-link>
        </el-dropdown-item>
        <el-dropdown-item style="font-size: 14px;padding: 5px 0">
          <router-link to="/change" tag="span">修改密码</router-link>
        </el-dropdown-item>
        <el-dropdown-item style="font-size: 14px;padding: 5px 0">
          <span @click="logout">退出</span>
        </el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  name: "Header",
  props: {
    collapseBtnClass: String,
    collapse: Function,
    user:Object,
  },
  computed:{
    menuList:{
      get(){
        return this.$store.state.menus.menuList
      }
    }
  },
  methods:{
    logout(){
      this.request.post("/logout").then(res =>{
        console.log(res.data.data)
        localStorage.clear()
        sessionStorage.clear()
        this.$store.commit("resetState")
        this.$router.push("/login")
      })
    }
  }
}
</script>

<style scoped>

</style>